package com.test.daily.leetcode.y2022.m05.day0516.v02;

import java.util.PriorityQueue;

/**
 * @author Tom on 2022/5/17
 */
public class Solution {
    public void Kstep(int[] arr, int k) {
        PriorityQueue<Integer> pq = new PriorityQueue<>(Math.min(k, arr.length));
        int i = 0;
        for (; i < Math.min(k, arr.length); i++) {
            pq.add(arr[i]);
        }
        int j = 0;
        for(;i< arr.length;i++){
            arr[j++] = pq.poll();
            pq.add(arr[i]);
        }
        while(!pq.isEmpty()){
            arr[j++] = pq.poll();
        }

    }
}
